{include admin.inc.header}

{include admin.inc.top}

<div class="container-fluid content-body">
	<div class="main">
		{include admin.inc.menu}

		<section class="right-section" id="right-section">
			<!-- start of inner-frame -->
			<div class="inner-iframe">

				{include admin.inc.bread}

				<!-- Nav tabs -->
				<ul class="nav nav-tabs">
					{loop $__sysmenus[$menu_key][subs] $k $v}
					<li{if $v[id]==$menu_id} class="active"{/if}><a href="{if $v[id]==$menu_id}javascript:;{else}/{$v[url]}{/if}"><i class="glyphicon glyphicon-th-list"></i> {$v[name]}</a></li>
					{/loop}
				</ul>

				<div class="inner-container">

					<!-- search form start -->
					<form class="form-inline form-search" role="form" id="search-form" autocomplete="off">
						<nav class="inline-form clearfix">
							<a class="btnlg mb fl" id="content-add" href="javascript:;"><i class="css-add"></i>添加菜单</a>
							<div class="r">
								<div class="form-group">
									<div class="input-group">
										<div class="input-group-addon">菜单名称</div>
										<input type="text" name="name" value="{$params[name]}" class="form-control input-sm">
									</div>
								</div>

								<button type="submit" class="btn btn-success btn-sm">
									<i class="glyphicon glyphicon-search"></i> 搜索</button>
							</div>
						</nav>

					</form><!-- END search form -->

					<form id="J_List_Form" autocomplete="off">
						<div class="table-responsive">
							<table class="table table-bordered table-hover" id="J_List_Table">
								<thead>
								<tr>
									<th>菜单名称</th>
									<th>菜单URL/标识</th>
									<th>是否显示</th>
									<th>创建时间</th>
									<th>操作</th>
								</tr>
								</thead>
								<tbody>
								{if empty($items)}
								<tr>
									<td class="no-records text-center">{$noRecords}</td>
								</tr>
								{/if}
								{loop $items $value}
								<tr data-id="{$value[id]}" data-pid="0" class="info" data-sort="{$value[sort_num]}">
									<td><label>{$value[name]}</label></td>
									<td>{$value[url]}</td>
									<td>
										<input type="checkbox" data-id="{$value[id]}" data-field="ishow" class="bswitch bswitch-list" data-size="mini"
											   {if $value[ishow]==1}checked{/if} data-on-text="显示" data-off-text="隐藏">
									</td>
									<td>{$value[addtime]}</td>
									<td>
										<a href="#" data-id="{$value[id]}" class="btn btn-primary btn-xs item-edit">
											<i class="glyphicon glyphicon-edit"></i> 修改</a>
										<a href="{$delete_url}/?id={$value[id]}" class="btn btn-danger btn-xs item-remove">
											<i class="glyphicon glyphicon-trash"></i> 删除</a>

										<a href="javascript:void(0);" class="btn btn-info btn-xs arrow-up">
											<i class="glyphicon glyphicon-arrow-up"></i> 上移</a>

										<a href="javascript:void(0);" class="btn btn-info btn-xs arrow-down">
											<i class="glyphicon glyphicon-arrow-down"></i> 下移</a>
									</td>
								</tr>
									{if !empty($value[subs])}
										{loop $value[subs] $subs}
										<tr data-id="{$subs[id]}" data-pid="{$value[id]}" data-sort="{$subs[sort_num]}">
											<td>|— {$subs[name]}</td>
											<td>{$subs[url]}</td>
											<td>
												<input type="checkbox" data-id="{$subs[id]}" data-field="ishow" class="bswitch bswitch-list" data-size="mini"
													   {if $subs[ishow]==1}checked{/if} data-on-text="显示" data-off-text="隐藏">
											</td>
											<td>{$subs[addtime]}</td>
											<td>
												<a href="javascript:;" data-id="{$subs[id]}" class="btn btn-primary btn-xs item-edit">
													<i class="glyphicon glyphicon-edit"></i> 修改</a>
												<a href="{$delete_url}/?id={$subs[id]}" class="btn btn-danger btn-xs item-remove">
													<i class="glyphicon glyphicon-trash"></i> 删除</a>

												<a href="javascript:void(0);" class="btn btn-info btn-xs arrow-up">
													<i class="glyphicon glyphicon-arrow-up"></i> 上移</a>

												<a href="javascript:void(0);" class="btn btn-info btn-xs arrow-down">
													<i class="glyphicon glyphicon-arrow-down"></i> 下移</a>
											</td>
										</tr>
										{/loop}
									{/if}
								{/loop}
								</tbody>
							</table>
						</div>
					</form>

					<!--<div class="button-group">-->
						<!--<a href="/admin/managerMenu/upcache?act=update_cache" class="btn btn-success ajaxproxy" data-loading-text="正在更新缓存……"-->
						   <!--proxy='{"method":"get"}'>-->
							<!--<em class="glyphicon glyphicon-saved"></em> 更新缓存</a>-->
					<!--</div>-->

					<div class="text-right">
						{$pagemenu}
					</div>

				</div>

			</div><!-- end of inner -->
		</section>

	</div>
</div>

{include admin.inc.footer}

<script type="text/html" id="content-add-template">

	<form role="form" class="content-add-form" id="content-add-form" autocomplete="off">

		<div class="form-element">
			<div class="form-group">
				<label><span class="asterisk">*</span>  上级菜单</label>
				<select class="form-control" name="data[pid]" cname="上级菜单" required>
					<option value="0">顶级菜单</option>
					{loop $menus $value}
					<option value="{$value[id]}" {[if item.pid == {$value[id]} ]}selected{[/if]}>{$value[name]}</option>
					{/loop}
				</select>
			</div>
			<p class="help-block"></p>
		</div>

		<div class="form-element">
			<div class="form-group">
				<label><span class="asterisk">*</span> 菜单名称</label>
				<input type="text" name="data[name]" value="{[item.name]}" maxlength="15" class="form-control" placeholder="菜单名称" required />
			</div>
			<p class="help-block"></p>
		</div>

		<div class="form-element">
			<div class="form-group">
				<label><span class="asterisk">*</span> 菜单URL</label>
				<input type="text" name="data[url]" value="{[item.url]}" maxlength="100" class="form-control" value="#" placeholder="菜单URL" required />
			</div>
			<p class="help-block">顶级菜单请慎重更改标识</p>
		</div>

		<div class="form-element">
			<div class="form-group">
				<label><span class="asterisk">*</span>  显示状态</label>
				<div class="bootstrap-switch-swrap">
					<input type="checkbox" class="bswitch bswitch-list" data-size="mini"  {[if item.ishow==1]}checked{[/if]} data-on-text="显示" data-off-text="隐藏">
					<input type="hidden" name="data[ishow]" value="{[item.ishow]}">
				</div>
			</div>
			<p class="help-block">被隐藏的菜单将不会在左侧菜单栏显示</p>
		</div>

		<input type="hidden" name="id" value="{[item.id]}">
	</form>
</script>

<script>
	seajs.use("managerMenu", function(exports) {
		exports.init({
			set_url : '/admin/managerMenu/set',
			exchange_sort_url : '/admin/managerMenu/exchangeSort',
			insert_url : '{$insert_url}',
			edit_url : '{$edit_url}',
			update_url : '{$update_url}',
		});
	});
</script>
</body>
</html>
